package org.project.d.network.coder;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.socket.DatagramPacket;
import io.netty.handler.codec.MessageToMessageDecoder;
import org.project.d.network.protocol.Packet;

import java.util.List;

/**
 * @author lin
 * @version V1.0
 * @description
 * @date 2020/6/11 4:42 下午
 */
public class UDPPacketDecoder extends MessageToMessageDecoder<DatagramPacket> {
    @Override
    protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, List<Object> out) throws Exception {
        Packet packet = Packet.decodePacket(msg);
        if (packet!=null){
            out.add(packet);
        }
    }
}
